<html>
<head>
<title>管理系统</title>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<#include "/xadmin/inc/common.html">
<script type="text/javascript">
	var grid;
	$(function() {
		//分类管理表格  
		grid = $('#usergrid').datagrid({
	     url:'usermanage-listuser',  
	     loadMsg:'数据加载中请稍后……',  
         striped: true,  
         singleSelect : true,  
         pageSize: [${syscfg.pageSize!10}],
         pageList: [${syscfg.pageList!10}],
         pagination: true,  
         rownumbers: true, 
         columns:[[  
             {field:'userid',title: '用户ID',align: 'center',width: '50'},  
             {field:'username',title: '用户名称',align: 'center',width: '80'},
             {field:'fullname',title: '真实姓名',align: 'center',width: '90'},
             {field:'depname',title: '所在部门',align: 'center',width: '90'},
             {field:'oskeyname',title: '权限',align: 'center',width: '90'},
             {field:'tel',title: '电话',align: 'center',width: '120'},
             {field:'useremail',title: '邮箱',align: 'center',width: '200'},
             {field:'lastlogin',title: '最后登录时间',align: 'center',width: '170'},
             {field:'userlogins',title: '登录次数',align: 'center',width: '60'},
             {field:'jinyong',title: '状态',align: 'center',width: '80',
             	formatter: function(value,rowdata,index){
             		var str = '';
					if(value ==1){
						str += '<a id="btnstate" class="l-btn l-btn-plain" href="javascript:jinyong('+rowdata.userid+','+rowdata.jinyong+')"><span class="l-btn-left"><span class="l-btn-text icon-no l-btn-icon-left">启用</span></span></a>';
					}else{
						str += '<a id="btnstate" class="l-btn l-btn-plain" href="javascript:jinyong('+rowdata.userid+','+rowdata.jinyong+')"><span class="l-btn-left"><span class="l-btn-text icon-ok l-btn-icon-left">禁用</span></span></a>';
					}
					return str;
				}
             }/*,
             {field:'shenhe',title: '审核',align: 'center',width: '80',
             	formatter: function(value,rowdata,index){
             		var str = '';
					if(value==1){
						str += '<a id="btnstate" class="l-btn l-btn-plain" href="javascript:shenhe('+rowdata.userid+','+rowdata.shenhe+')"><span class="l-btn-left"><span class="l-btn-text icon-undo l-btn-icon-left">取消</span></span></a>';
					}else{
						str += '<a id="btnstate" class="l-btn l-btn-plain" href="javascript:shenhe('+rowdata.userid+','+rowdata.shenhe+')"><span class="l-btn-left"><span class="l-btn-text icon-redo l-btn-icon-left">审核</span></span></a>';
					}
					return str;
				}}*/
         ]],
         toolbar : '#toolbar'
     });
  })
  //新增用户
	function doAdd() {
		var url = '${request.contextPath}/xadmin/system/usermanage-userwindow';
		top.modalwindow(url, grid,{ width:550,height:360,title:'新增用户信息'});
	}
	//工具栏修改用户
	function doEdit(flid) {
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		var url = '${request.contextPath}/xadmin/system/usermanage-userwindow?userid='+selected.userid;
		top.modalwindow(url, grid,{width:550,height:360,title:'修改用户信息'});
	}
	//工具栏删除用户
	function doDel(){
		var selected = grid.datagrid('getSelected');
		if(!selected){
			$.messager.alert('提示',"请选择相关数据进行操作！");
			return;
		}
		$.messager.confirm('系统提示', '<br>&nbsp;&nbsp;&nbsp;&nbsp;你确定要删除该信息?', function(r) {
			if (r) {
				$.post("usermanage-deluser", { "userid": selected.userid},
				   function(data){
				   	grid.datagrid('reload'); 
				   	top.messagershow(data);
				});
			}
		});
	}
	//
	function jinyong(userid,result){
		if(result==0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("usermanage-updateuserzt.do", {"userid": userid, "zt":+result},
		   	function(data){
		   		grid.datagrid('reload'); 
		   		top.messagershow(data);
		});
	}
	//审核
	function shenhe(userid,result){
		if(result==0){
			result = 1;
		}else{
			result = 0;
		}
		$.post("usermanage-updateuserzt", { "userid": userid, "zt":result},
		   	function(data){
		   		grid.datagrid('reload'); 
		   		top.messagershow(data);
		});
	}
	//刷新
	function doReload(){
		$('#toolbar input').val('');
		grid.datagrid('reload',{});
	}
	//搜索
	function doSearch(){
		var params = {};
		if($('#username').val()){
			params['username'] = $('#username').val();
		}
		if($('#fullname').val()){
			params['fullname'] = $('#fullname').val();
		}
		if($('#oskey').combobox('getValue')){
			params['oskey'] = $('#oskey').combobox('getValue');
		}
		$('#usergrid').datagrid('reload',params);
	}
</script>

</head>
<body>
<table id="usergrid" data-options="fit:true,border:false"></table>
<div id="toolbar" style="display: none;">
<table border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td valign="center">
	&nbsp;用户名：	<input class="easyui-validatebox" type="text" id="username" name="username" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">
	&nbsp;真实姓名：<input class="easyui-validatebox" type="text" id="fullname" name="fullname" maxlength="30" style="width:150px;">
	</td>
	<td valign="center">
	&nbsp;权限：<input id="oskey" class="easyui-combobox" name="oskey" style="width:150px;" data-options="valueField:'jsdm',textField:'jsmc',url:'qxmanage-listrole'" />
	</td>
	<td valign="center">	
	<a href="javascript:doSearch();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
	</td>
	<td valign="center">
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	</td>
	<td valign="center">
	<a href="javascript:doReload();" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
	<td valign="center" align="left">
	<a href="javascript:doAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doEdit();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
	</td>
	<td valign="center" align="left">
	<a href="javascript:doDel();" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">删除</a>
	</td>
	<td valign="center"><div class="datagrid-btn-separator"></div></td>
</tr>
</table>
</div>
</body>
</html>